package com.qr.service.wmyh.impl;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.mapping.ResultMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.krui.helper.db.DBHelper;
import cn.krui.helper.db.DataPage;
import com.qr.bean.wmyh.JbrUserExtractionApply;
import com.qr.bean.wmyh.JbrUserExtractionApplyView;
import com.qr.controller.WmyhBase;
import com.qr.mapper.wmyh.JbrUserExtractionApplyMapper;
import com.qr.mapper.wmyh.JbrUserExtractionApplyMapperView;
import com.qr.service.wmyh.JbrUserExtractionApplyService;
//import org.apache.dubbo.config.annotation.Service;

/**
 * @author: zc
 * email: zc8023zs@163.com
 * create_time: 2020/8/11 13:03:06
 */
@Service
//@Service(version = "1.0.0",group="dubbo")
public class JbrUserExtractionApplyServiceImpl implements JbrUserExtractionApplyService{
    @Autowired
    private JbrUserExtractionApplyMapper jbrUserExtractionApplyMapper;

    @Autowired
    private JbrUserExtractionApplyMapperView jbrUserExtractionApplyMapperView;
    
    @Autowired
    private DBHelper dbHelper;

    /**
     * 构造查询条件
     */
    private QueryWrapper<JbrUserExtractionApply> InitWrapper(JbrUserExtractionApply where){
        QueryWrapper<JbrUserExtractionApply> whereWrapper = new QueryWrapper<JbrUserExtractionApply>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getTransfer_num()!=null){
			whereWrapper.eq("transfer_num",where.getTransfer_num());
		}
        if(where.getPrice()!=null){
			whereWrapper.eq("price",where.getPrice());
		}
        if(where.getApproval_status()!=null){
			whereWrapper.eq("approval_status",where.getApproval_status());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getOperator_id()!=null){
			whereWrapper.eq("operator_id",where.getOperator_id());
		}
        if(where.getPlatform_trade_fee()!=null){
			whereWrapper.eq("platform_trade_fee",where.getPlatform_trade_fee());
		}
        if(where.getOther_fee()!=null){
			whereWrapper.eq("other_fee",where.getOther_fee());
		}
        if(where.getCollection_number()!=null){
			whereWrapper.eq("collection_number",where.getCollection_number());
		}
        if(where.getPay_flow_num()!=null){
			whereWrapper.eq("pay_flow_num",where.getPay_flow_num());
		}
        if(where.getApply_time()!=null){
			whereWrapper.eq("apply_time",where.getApply_time());
		}
        if(where.getApproval_time()!=null){
			whereWrapper.eq("approval_time",where.getApproval_time());
		}
        if(where.getApproval_admin_id()!=null){
			whereWrapper.eq("approval_admin_id",where.getApproval_admin_id());
		}
        if(where.getRemark()!=null){
			whereWrapper.eq("remark",where.getRemark());
		}
        if(where.getType()!=null){
			whereWrapper.eq("type",where.getType());
		}
        if(where.getRe_user_name()!=null){
			whereWrapper.eq("re_user_name",where.getRe_user_name());
		}
        if(where.getBank_code()!=null){
			whereWrapper.eq("bank_code",where.getBank_code());
		}
        if(where.getBank_name()!=null){
			whereWrapper.eq("bank_name",where.getBank_name());
		}
        if(where.getWx_app_id()!=null){
			whereWrapper.eq("wx_app_id",where.getWx_app_id());
		}
        return whereWrapper;
    }

    private QueryWrapper<JbrUserExtractionApplyView> InitWrapperView(JbrUserExtractionApplyView where){
        QueryWrapper<JbrUserExtractionApplyView> whereWrapper = new QueryWrapper<JbrUserExtractionApplyView>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getTransfer_num()!=null){
			whereWrapper.eq("transfer_num",where.getTransfer_num());
		}
        if(where.getPrice()!=null){
			whereWrapper.eq("price",where.getPrice());
		}
        if(where.getApproval_status()!=null){
			whereWrapper.eq("approval_status",where.getApproval_status());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getOperator_id()!=null){
			whereWrapper.eq("operator_id",where.getOperator_id());
		}
        if(where.getPlatform_trade_fee()!=null){
			whereWrapper.eq("platform_trade_fee",where.getPlatform_trade_fee());
		}
        if(where.getOther_fee()!=null){
			whereWrapper.eq("other_fee",where.getOther_fee());
		}
        if(where.getCollection_number()!=null){
			whereWrapper.eq("collection_number",where.getCollection_number());
		}
        if(where.getPay_flow_num()!=null){
			whereWrapper.eq("pay_flow_num",where.getPay_flow_num());
		}
        if(where.getApply_time()!=null){
			whereWrapper.eq("apply_time",where.getApply_time());
		}
        if(where.getApproval_time()!=null){
			whereWrapper.eq("approval_time",where.getApproval_time());
		}
        if(where.getApproval_admin_id()!=null){
			whereWrapper.eq("approval_admin_id",where.getApproval_admin_id());
		}
        if(where.getRemark()!=null){
			whereWrapper.eq("remark",where.getRemark());
		}
        if(where.getType()!=null){
			whereWrapper.eq("type",where.getType());
		}
        if(where.getRe_user_name()!=null){
			whereWrapper.eq("re_user_name",where.getRe_user_name());
		}
        if(where.getBank_code()!=null){
			whereWrapper.eq("bank_code",where.getBank_code());
		}
        if(where.getBank_name()!=null){
			whereWrapper.eq("bank_name",where.getBank_name());
		}
        if(where.getWx_app_id()!=null){
			whereWrapper.eq("wx_app_id",where.getWx_app_id());
		}
        return whereWrapper;
    }

    /**
     * 团长佣金提现申请明细新增
     * @param model 团长佣金提现申请明细实体
     * @return 影响行数
     */
	@Override
    public Integer add(JbrUserExtractionApply model){
        return jbrUserExtractionApplyMapper.insert(model);
    }

    /**
     * 团长佣金提现申请明细修改byid
     * @param model 团长佣金提现申请明细实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserExtractionApply model) {
        return jbrUserExtractionApplyMapper.updateById(model);
    }

    /**
     * 团长佣金提现申请明细修改by条件
     * @param model 团长佣金提现申请明细实体
     * @param where 团长佣金提现申请明细条件
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserExtractionApply model, Wrapper<JbrUserExtractionApply> where) {
        return jbrUserExtractionApplyMapper.update(model, where);
    }

    /**
     * 团长佣金提现申请明细修改by条件-自动封装Wrapper
     * @param model 团长佣金提现申请明细实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserExtractionApply model, JbrUserExtractionApply where) {
        Wrapper<JbrUserExtractionApply> wrapper = InitWrapper(where);
        return update(model, wrapper);
    }

    /**
     * 团长佣金提现申请明细修改bySQL *version_id = newVersion where version_id = oldVersion
     * @param fields 修改的数据 col1=xx,col2=yy
     * @param where 参数化条件 col1=#{col1}
     * @param params 条件参数 col1=xx
     * @return 影响行数
     */
	@Override
    public Integer update(Map<String, Object> fields, String where, Map<String, Object> params) {
        return dbHelper.update("jbr_user_extraction_apply", fields, where, params);
    }

    /**
     * 团长佣金提现申请明细删除byid
     * @param id 团长佣金提现申请明细主键
     * @return 影响行数
     */
	@Override
    public Integer del(int id) {
        return jbrUserExtractionApplyMapper.deleteById(id);
    }

    /**
     * 团长佣金提现申请明细删除by条件
     * @param where 团长佣金提现申请明细条件
     * @return 影响行数
     */
	@Override
    public Integer del(Wrapper<JbrUserExtractionApply> where) {
        return jbrUserExtractionApplyMapper.delete(where);
    }

    /**
     * 团长佣金提现申请明细删除by条件-自动封装Wrapper
     * @param where 团长佣金提现申请明细条件
     * @return 影响行数
     */
    @Override
    public Integer del(JbrUserExtractionApply where) { 
        Wrapper<JbrUserExtractionApply> wrapper = InitWrapper(where);
        return del(wrapper);
    }

    /**
     * 团长佣金提现申请明细批量删除byid
     * @param ids 团长佣金提现申请明细主键集合
     * @return 影响行数
     */
	@Override
    public Integer del(List<Integer> ids){
        return jbrUserExtractionApplyMapper.deleteBatchIds(ids);
    }

    /**
     * 团长佣金提现申请明细批量删除bymap条件
     * @param map 团长佣金提现申请明细map条件
     * @return 影响行数
     */
	@Override
    public Integer del(Map<String,Object> map){
        return jbrUserExtractionApplyMapper.deleteByMap(map);
    }

    /**
     * 团长佣金提现申请明细详情byid
     * @param id 团长佣金提现申请明细主键
     * @return 团长佣金提现申请明细详情
     */
	@Override
    public JbrUserExtractionApplyView info(int id){
        return jbrUserExtractionApplyMapperView.selectById(id);
    }

    /**
     * 团长佣金提现申请明细详情by条件
     * @param where 团长佣金提现申请明细条件
     * @return 团长佣金提现申请明细详情
     */
	@Override
    public JbrUserExtractionApplyView info(Wrapper<JbrUserExtractionApplyView> where){
        return jbrUserExtractionApplyMapperView.selectOne(where);
    }

    /**
     * 团长佣金提现申请明细详情by条件-自动封装Wrapper
     * @param where 团长佣金提现申请明细条件
     * @return 团长佣金提现申请明细详情
     */
	@Override
    public JbrUserExtractionApplyView info(JbrUserExtractionApplyView where) {
        Wrapper<JbrUserExtractionApplyView> wrapper = InitWrapperView(where);
        return info(wrapper);
    }

    /**
     * 团长佣金提现申请明细详情bySQL
     * @param columns  列名col1,col2,col3^
     * @param where 条件 col1=#{col1}
     * @param params col1:xx
     * @param mappings col1->col1
     * @return
     */
	@Override
    public JbrUserExtractionApply info(String columns, String where, Map<String, Object> params, ResultMapping mappings) {
        return dbHelper.selectOne(columns, "jbr_user_extraction_apply", where, params, JbrUserExtractionApply.class, mappings);
    }

    /**
     * 团长佣金提现申请明细批量查询byid
     * @param ids 团长佣金提现申请明细主键集合
     * @return 团长佣金提现申请明细列表
     */
	@Override
    public List<JbrUserExtractionApplyView> select(List<Integer> ids){
        return jbrUserExtractionApplyMapperView.selectBatchIds(ids);
    }

    /**
     * 团长佣金提现申请明细批量查询by条件
     * @param where 团长佣金提现申请明细条件
     * @return 团长佣金提现申请明细列表
     */
	@Override
    public List<JbrUserExtractionApplyView> select(Wrapper<JbrUserExtractionApplyView> where){
        return jbrUserExtractionApplyMapperView.selectList(where);
    }

    /**
     * 团长佣金提现申请明细批量查询by条件-自动封装Wrapper
     * @param where 团长佣金提现申请明细条件
     * @return 团长佣金提现申请明细列表
     */
    @Override
    public List<JbrUserExtractionApplyView> select(JbrUserExtractionApplyView where) {
        Wrapper<JbrUserExtractionApplyView> wrapper = InitWrapperView(where);		
        return select(wrapper);
    }

    /**
     * 团长佣金提现申请明细批量查询bymap条件
     * @param map 团长佣金提现申请明细map条件
     * @return 团长佣金提现申请明细列表
     */
	@Override
    public List<JbrUserExtractionApplyView> select(Map<String,Object> map){
        return jbrUserExtractionApplyMapperView.selectByMap(map);
    }

    /**
     * 团长佣金提现申请明细批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
	@Override
    public IPage<JbrUserExtractionApplyView> select(IPage<JbrUserExtractionApplyView> page, Wrapper<JbrUserExtractionApplyView> where){
        return jbrUserExtractionApplyMapperView.selectPage(page, where);
    }

    /**
     * 团长佣金提现申请明细批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
    @Override
    public IPage<JbrUserExtractionApplyView> select(IPage<JbrUserExtractionApplyView> page, JbrUserExtractionApplyView where) {
		Wrapper<JbrUserExtractionApplyView> wrapper = InitWrapperView(where);		
        return select(page, wrapper);
    }

    /**
     * 团长佣金提现申请明细查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(Wrapper<JbrUserExtractionApplyView> where){
        return jbrUserExtractionApplyMapperView.selectCount(where);
    }

    /**
     * 团长佣金提现申请明细查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(JbrUserExtractionApplyView where){
		Wrapper<JbrUserExtractionApplyView> wrapper = InitWrapperView(where);
        return selectCount(wrapper);
    }

    /**
     * 团长佣金提现申请明细批量查询bySQL条件分页
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param orderBy 排序字段
     * @param params 参数化 col1=xx
     * @param pageNumber 分页页码
     * @param pageSize 每页行数
     * @param mappings 查询列和实体映射
     * @return 分页之后的数据含总行数
     */
	@Override
    public DataPage<JbrUserExtractionApplyView> select(String columns, String where, String orderBy, Map<String, Object> params, int pageNumber, int pageSize, ResultMapping mappings){
        return dbHelper.select(columns, "jbr_user_extraction_apply", where, orderBy, params, pageNumber, pageSize, JbrUserExtractionApplyView.class,mappings);
    }

    /**
     * 团长佣金提现申请明细批量查询bySQL条件
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param params 参数化 col1=xx
     * @param mappings 查询列和实体映射
     * @return 栏目扩展列表
     */
	@Override
    public List<JbrUserExtractionApplyView> select(String columns, String where, Map<String, Object> params, ResultMapping mappings){
        return dbHelper.select(columns,"jbr_user_extraction_apply",where,params,JbrUserExtractionApplyView.class,mappings);
    }
}